<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../layui/css/layui.css" />
		<style>
			* {
				margin: 0px;
			}

			.headBtn~div,
			.headBtn {
				width: 869px;
			}
			/*表头居中、高和行高的设置*/
			
			#chooseArticle+div div table tr th div {
				text-align: center;
				padding: 0px;
			}
			/*表体字体大小 、居中、高和行高的设置*/
			
			#chooseArticle+div div table tr td div {
				text-align: center;
				padding: 0px;
			}
			/*商品清单表头居中、高和行高的设置*/
			
			#stockMarketDetail+div div table tr th div {
				text-align: center;
				padding: 0px;
			}
			/*商品清单表体字体大小 、居中、高和行高的设置*/
			
			#stockMarketDetail+div div table tr td div {
				text-align: center;
				padding: 0px;
			}
			/*自动提醒表头居中、高和行高的设置*/
			
			#ermSurfaceInfo+div div table tr th div {
				text-align: center;
				padding: 0px;
			}
			/*自动提醒表体字体大小 、居中、高和行高的设置*/
			
			#ermSurfaceInfo+div div table tr td div {
				text-align: center;
				padding: 0px;
			}
			
			/*商品批次表头居中、高和行高的设置*/
			
			#repertoryLotInfoVhart+div div table tr th div {
				text-align: center;
				padding: 0px;
			}
			/*商品批次表体字体大小 、居中、高和行高的设置*/
			
			#repertoryLotInfoVhart+div div table tr td div {
				text-align: center;
				padding: 0px;
			}
		</style>
	</head>

	<body>
		<div>
			<!--库存报警 头部选项-->
			<div class="layui-fluid headBtn layui-panel" style="text-align:center;height:40px;padding-top:10px;">
				 <span style="font-size:20px;">库存报警</span>
			</div>

			<!--库存报警表-->
			<div class="layui-fluid" style="width: 900px;">
				<div class="layui-tab-item layui-show">
					<!--库存报警查询-->
					<table class="layui-hide" id="chooseArticle" lay-filter="chooseArticle"></table>
				</div>
			</div>

			<!--进货销售明细的商品名称-->
			<div class="layui-fluid layui-panel" id="queryDateScope">
				<div class="layui-inline" style="text-indent:1em;">进货销售明细:</div>
				<span class="layui-inline" style="width:250px; color: red;" id="stockMarketInveDescName"></span>
				<div class="layui-form layui-inline">
					<div class="layui-form-item" style="margin:5px 0px 0px;">
						<div class="layui-inline">
							<label class="layui-form-label" style="width:100px;">查询日期范围</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input" id="shijianone" placeholder=" - ">
							</div>
						</div>
					</div>
				</div>
				<button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" style="margin: 0px 50px 0px 10px;">查询</button>
				<!--<button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm">查询单据</button>-->
			</div>

			<div class="layui-fluid" style="width: 900px;">
				<div class="layui-tab-item layui-show">
					<!--进货销售明细-->
					<table class="layui-hide" id="stockMarketDetail" lay-filter="currentTableFilter"></table>
				</div>
			</div>
		</div>

		<!--修改商品-->
		<div id="revampArticlePopup" style="display: none;">
			<div style="border: 1px #B4B4B4 solid; width:670px; margin:5px auto 0px; padding:5px 0px 20px;">
				<form class="layui-form layui-inline" lay-filter="commodityInformationTransfer">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">所属类别</label>
							<div class="layui-input-inline">
								<input type="tel" disabled="disabled" lay-verify="required|phone" autocomplete="off" class="layui-input"
									name="proTypeName">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">商品编号</label>
							<div class="layui-input-inline">
								<input type="text" disabled="disabled" lay-verify="email" autocomplete="off" class="layui-input"
									name="proId"/>
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">商品名称</label>
							<div class="layui-input-inline">
								<input type="tel" disabled="disabled" lay-verify="required|phone" autocomplete="off" class="layui-input"
									   name="inveDescName"/>
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">商品条码</label>
							<div class="layui-input-inline">
								<input type="text" disabled="disabled" lay-verify="email" autocomplete="off" class="layui-input"
									name="proBarCodes">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">名称简拼</label>
							<div class="layui-input-inline">
								<input type="tel" disabled="disabled" lay-verify="required|phone" autocomplete="off" class="layui-input"
									name="proVulgo">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">单位</label>
							<div class="layui-input-inline">
								<input type="text" disabled="disabled" lay-verify="email" autocomplete="off" class="layui-input"
									name="inveDescUnit">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">产品规格</label>
							<div class="layui-input-inline">
								<input type="tel" disabled="disabled" lay-verify="required|phone" autocomplete="off" class="layui-input"
									name="inveDescSize">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">药剂类型</label>
							<div class="layui-input-inline">
								<input type="text" disabled="disabled" lay-verify="email" autocomplete="off" class="layui-input"
									name="agentiaTypeName">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">预设销价</label>
							<div class="layui-input-inline">
								<input type="tel" disabled="disabled" lay-verify="required|phone" autocomplete="off" class="layui-input"
									name="proSalePrice">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">预设进价</label>
							<div class="layui-input-inline">
								<input type="text" disabled="disabled" lay-verify="email" autocomplete="off" class="layui-input"
									name="proBid">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">库存下限</label>
							<div class="layui-input-inline">
								<input type="number" id="proStockLower" name="proStockLower" lay-verify="required|phone" autocomplete="off" class="layui-input"
									   style="border:1px solid black;" min="0"/>
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">保质期</label>
							<div class="layui-input-inline">
								<input type="text" disabled="disabled" lay-verify="email" autocomplete="off" class="layui-input"
									name="proKeepDate">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">通用名</label>
							<div class="layui-input-inline">
								<input type="tel" disabled="disabled" lay-verify="required|phone" autocomplete="off" class="layui-input"
									name="proVulgo">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">批准文号</label>
							<div class="layui-input-inline">
								<input type="text" disabled="disabled" lay-verify="email" autocomplete="off" class="layui-input"
									name="proPostil">
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">生产厂商</label>
							<div class="layui-input-inline">
								<input type="tel" disabled="disabled" lay-verify="required|phone" autocomplete="off" class="layui-input"
									name="inveDescManufacturer">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">生产许可</label>
							<div class="layui-input-inline">
								<input type="text" name="" lay-verify="email" autocomplete="off" class="layui-input" style="border:1px solid black;"/>
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">备注</label>
							<div class="layui-input-inline">
								<input type="tel" disabled="disabled" lay-verify="required|phone" autocomplete="off" class="layui-input"
									name="proComment">
							</div>
						</div>
					</div>
				</form>

				<div class="layui-inline">
					<div class="layui-form-item layui-inline">
						<div class="layui-input-inline" style="margin:13px 0px 0px 40px; width:120px;">
							<input type="radio" disabled="disabled" style="vertical-align:middle; margin-right:5px;">该商品可拆零
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-lable layui-inline">调出仓库:</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-input" value="" disabled="disabled" id="transferOutNumber"/>
						</div>
						<label style="color:red;">折零系数是该商品折零后的个数</label>
					</div>
				</div>
			</div>

			<!--修改商品的保存和退出按钮-->
			<div style="text-align:center; margin:15px 0px;">
				<button class="layui-btn  layui-btn-radius" id="revampArticlePopupSave">保存</button>
				<button class="layui-btn  layui-btn-radius" id="revampArticlePopupSecede">退出</button>
			</div>

		</div>

		<!--商品批次-->
		<div id="repertoryLotInfo" style="display:none;">
			<fieldset class="table-search-fieldset" style="margin:5px; padding:5px;">
				<legend style="margin-left: 15px;">商品信息</legend>
				
				<div class="layui-inline" style="width:170px; margin-left:75px;"><span>商品编号：</span><span>1212312</span></div>
				<div class="layui-inline" style="width:170px;"><span>商品名称：</span><span>1212312</span></div>
				<div class="layui-inline" style="width:140px;"><span>单位：</span><span>1212312</span></div>
				<div class="layui-inline" style="width:170px;"><span>规格型号：</span><span>1212312</span></div>
			</fieldset>
			
			<fieldset class="table-search-fieldset" style="margin:5px; padding:5px;">
				<legend style="margin-left:15px;">该商品批次信息</legend>
				
				<div class="layui-tab-item layui-show" style="width:765px;">
					<!--该商品批次-->
					<table class="layui-hide" id="repertoryLotInfoVhart" lay-filter="currentTableFilter"></table>
				</div>
			</fieldset>
			
			<button class="layui-btn layui-btn-radius layui-inline" style="margin:10px 350px;">退出</button>
		</div>

		<!--自动提醒-->
		<div id="eventReminderManagement" style="display:none;">
			<div class="layui-panel" style="display:flex; justify-content: space-evenly; padding: 10px 0px;">
				<button class="layui-btn  layui-btn-radius ermAdd">增加</button>
				<button class="layui-btn  layui-btn-radius ermAmend">修改</button>
				<button class="layui-btn  layui-btn-radius">删除</button>
			</div>
			<div class="layui-panel layui-form">
				<div class="layui-form-item layui-inline" style="margin:15px 0px;">
					<div class="layui-inline" style="margin: 0px;">
						<label class="layui-form-label" style="padding:9px 5px 0px; width:100px;">请选择时间段</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-input" id="shijian" placeholder=" - ">
						</div>
					</div>
					
					<div class="layui-form-item layui-inline" style="margin:0px;">
						<label class="layui-form-label" style="padding:9px 15px 0px; width:160px;">请输入相关内容进行查询</label>
						<div class="layui-input-inline">
						    <input type="text" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
						</div>
					</div>
				</div>
				<button class="layui-btn  layui-btn-radius">查询</button>
			</div>
			
			<div>
				<div class="layui-tab-item layui-show" style="width:635px; margin:0px auto;">
					<!--该商品批次-->
					<table class="layui-hide" id="ermSurfaceInfo" lay-filter="currentTableFilter"></table>
				</div>
			</div>
		</div>
		
		<!--增加提醒-->
		<div id="ermAddRemind" style="display:none">
			<fieldset class="table-search-fieldset" style="margin:5px; padding:5px;">
				<legend style="margin-left: 15px;">提醒设置</legend>
				
				<div><span>提醒内容：</span></div>
				<div class="layui-form-item" style="margin-bottom:0px;">
				    <div class="layui-input-inline" style="margin-left:80px; width:100px;">
				      	<input type="radio" name="sex" style="vertical-align:middle;" checked="">库存报警提示
				      	<input type="radio" name="sex" style="vertical-align:middle;">药品过期提示
				    </div>
				</div>
				<div class="layui-inline" style="width:500px;">
				   	<span class="layui-inline" style="width:60px; margin-left:80px;">提醒还有</span>
				    <input type="text" style="width:100px; margin:0px; vertical-align:middle;"/>个月到期的药品
				</div>
				
				<div>
					<form class="layui-form layui-input-inline">
						<div class="layui-input-block" style="margin-top: 10px;">
							<label class="layui-form-lable">提醒对象:</label>
							<div class="layui-input-inline">
								<select>
									<option>全体成员</option>
									<option>admin</option>
								</select>
							</div>
						</div>
						<div class="layui-input-block" style="margin-top: 10px;">
							<label class="layui-form-lable">提醒方式:</label>
							<div class="layui-input-inline">
								<select>
									<option>一次性提醒</option>
									<option>每日提醒</option>
								</select>
							</div>
						</div>
						<div class="layui-input-block" style="margin-top: 10px;">
							<div class="layui-inline">
						      	<label class="layui-form-label" style="padding: 9px 4px 9px 0px; width:60px;">提醒时间:</label>
						      	<div class="layui-input-inline">
						      	  	<input type="text" class="layui-input" id="test5" placeholder="yyyy-MM-dd HH:mm:ss">
						    	</div>
						    </div>
						</div>
					</form>
				</div>
			</fieldset>
			
			<div style="display: flex; justify-content: space-evenly; ">
				<button class="layui-btn  layui-btn-radius">保存</button>
				<button class="layui-btn  layui-btn-radius">关闭</button>
			</div>
		</div>
		
		<script src="../../layui/layui.js" charset="utf-8"></script>
		<script>
			layui.use(['form', 'table', 'laydate'], function() {
				var form = layui.form,
					layer = layui.layer,
					$ = layui.$,
					table = layui.table;
				var laydate = layui.laydate;

                laydate.render({
                    elem: '#shijianone',
                    range: true
                });
				//日期范围
				laydate.render({
					elem: '#shijian',
					range: true
				});

                //时间选择器
                laydate.render({
                    elem: '#test5'
                    ,type: 'datetime'
                });



				/*获取表格一行数据*/
				var row;
                /*表格这一行的下标*/
                var surfaceIndex = 0 ;
                /*获取要关闭的弹窗index值*/
                var index;
                /*获取商品编号*/
                var proId;

                /*关闭弹窗*/
                function exit() {
                    layer.close(index);
                }

                /*库存报警表所选列表添加样式*/
                /*单击*/
                table.on('row(chooseArticle)', function(obj){
                    obj.tr.addClass('layui-bg-green').siblings().removeClass('layui-bg-green');
                    row = obj.data;
                    $('#stockMarketInveDescName').html(row.inveDescName);
                    proId = row.productInfo.proId;

                    stockMarketDetail();
                });
                /*双击*/
                table.on('rowDouble(chooseArticle)', function(){
                    revampArticle(row);
                });
                /*退出按钮*/
				$('#revampArticlePopupSecede').click(function () {
					exit();
                });
				/*保存按钮*/
				$('#revampArticlePopupSave').click(function () {
				    exit();
					var proStockLower = $('#proStockLower').val();
					proId = row.productInfo.proId;
					$.ajax({
						type: 'GET',
						url: '/updateProductInfoproStockLower/'+proStockLower+'/'+proId
					});
                });

                /*报警商品的表格*/
				table.render({
					elem: '#chooseArticle',
					url: '/searchAlarmCommodity',
					data: [],
					height: '290',
					defaultToolbar: ['filter', 'exports', 'print', {
						title: '提示',
						layEvent: 'LAYTABLE_TIPS',
						icon: 'layui-icon-tips'
					}],
					cols: [
						[{
							field: 'proId',
							width: 150,
							title: '商品编号',
                            templet:function (obj) {
								return obj.productInfo.proId;
                            }
						}, {
							field: 'inveDescName',
							width: 160,
							title: '商品名称'
						}, {
							field: 'inveDescUnit',
							width: 60,
							title: '单位'
						}, {
							field: 'inveDescSize',
							width: 120,
							title: '产品规格'
						}, {
							field: 'inveDescManufacturer',
							title: '生产厂商',
							width: 140
						}, {
							field: 'inveDescPrice',
							width: 60,
							title: '单价'
						}, {
							field: 'inveDescInventoryNum',
							width: 100,
							title: '当前库存'
						}, {
							field: 'proStockLower',
							width: 100,
							title: '最低库存',
							templet: function (obj) {
								return obj.productInfo.proStockLower;
                            }
						}]
					],done: function (obj) {
					    row = obj.data[0];
                        $('#chooseArticle~div tr[data-index=0]').addClass('layui-bg-green');
                        $('#stockMarketInveDescName').html(row.inveDescName);
                    }
				});



				/*进货销售明细表*/
				var stockMarketDetail = function () {
                    table.render({
                        elem: '#stockMarketDetail',
                        //url: '',
                        data: [],
                        height: '195',
                        defaultToolbar: ['filter', 'exports', 'print', {
                            title: '提示',
                            layEvent: 'LAYTABLE_TIPS',
                            icon: 'layui-icon-tips'
                        }],
                        cols: [
                            [{
                                field: 'id',
                                width: 90,
                                title: '日期'
                            }, {
                                field: 'username',
                                width: 100,
                                title: '单据号'
                            }, {
                                field: 'sex',
                                width: 150,
                                title: '说明'
                            }, {
                                field: 'city',
                                width: 120,
                                title: '供货商/客户'
                            }, {
                                field: 'sign',
                                title: '入库数',
                                width: 80
                            }, {
                                field: 'experience',
                                width: 80,
                                title: '出库数'
                            }, {
                                field: 'experience',
                                width: 110,
                                title: '仓库'
                            }, {
                                field: 'experience',
                                width: 80,
                                title: '经办人'
                            }, {
                                field: 'experience',
                                width: 80,
                                title: '操作员'
                            }]
                        ]
                    });
                }
                stockMarketDetail();

				/*该商品批次*/
				table.render({
					elem: '#repertoryLotInfoVhart',
					//url: '../api/aaaaa.json',
					data: [],
					height: '300',
					defaultToolbar: ['filter', 'exports', 'print', {
						title: '提示',
						layEvent: 'LAYTABLE_TIPS',
						icon: 'layui-icon-tips'
					}],
					cols: [
						[{
							field: 'id',
							width: 100,
							title: '商品编号'
						}, {
							field: 'username',
							width: 140,
							title: '商品名称'
						}, {
							field: 'sex',
							width: 100,
							title: '产品批次'
						}, {
							field: 'city',
							width: 110,
							title: '有效期至'
						}, {
							field: 'sign',
							title: '进货日期',
							width: 110
						}, {
							field: 'experience',
							width: 90,
							title: '库存数量'
						}, {
							field: 'experience',
							width: 120,
							title: '仓库名称'
						}]
					]
				});
				
				/*自动提醒*/
				table.render({
					elem: '#ermSurfaceInfo',
					//url: '../api/aaaaa.json',
					data: [],
					height: '280',
					defaultToolbar: ['filter', 'exports', 'print', {
						title: '提示',
						layEvent: 'LAYTABLE_TIPS',
						icon: 'layui-icon-tips'
					}],
					cols: [
						[{
							field: 'id',
							width: 120,
							title: '提醒时间'
						}, {
							field: 'username',
							width: 120,
							title: '提醒方式'
						}, {
							field: 'sex',
							width: 120,
							title: '提醒对象'
						}, {
							field: 'city',
							width: 120,
							title: '提醒内容'
						}, {
							field: 'sign',
							title: '状态',
							width: 60
						}, {
							field: 'experience',
							width: 90,
							title: '操作员'
						}]
					]
				});
				
				/*修改商品*/
				$('#revampArticle').click(function() {
					revampArticle(row);
				});
				function revampArticle(data) {
					 index=layer.open({
						type: 1,
						title: '商品信息(库存调拨)',
						content: $('#revampArticlePopup'),
						area: ["720px", "620px"],
                        success:function () {
                            form.val('commodityInformationTransfer' , data.productInfo);
                            form.val('commodityInformationTransfer' , data.productType);
                            form.val('commodityInformationTransfer' , data.agentiaType);
                            form.val('commodityInformationTransfer',data);

                            /*调出仓库数量*/
                            $('#transferOutNumber').val(data.purchaseStockDesc.purStoDescNum - data.inveDescInventoryNum);
                        }
					})
				};
				
				/*产品批次*/
				$('#repertoryLot').click(function(){
					repertoryLot();
				});
				function repertoryLot() {
					layer.open({
						type: 1,
						title: '商品批次信息',
						content: $('#repertoryLotInfo'),
						area: ["790px", "540px"]
					})
				};
				
				/*进退货参考*/
				$('#enterRetreatMoneyReference').click(function(){
					index = layer.open({
							title: '进退货参考',
							type: 2,
							shade: 0.2,
							maxmin: true,
							shadeClose: true,
							area: ['100%', '100%'],
							content: 'enterRetreatMoneyReference.html',
						});
						$(window).on("resize", function() {
							layer.full(index);
						});
				});
				
				/*自动提醒*/
				$('#automaticCheck').click(function(){
					automaticCheck();
				});
				function automaticCheck() {
					layer.open({
						type: 1,
						title: '事件提醒管理',
						content: $('#eventReminderManagement'),
						area: ["790px", "540px"]
					})
				};
				
				/*增加提醒*/
				$('.ermAdd').click(function(){
					ermAdd();
				});
				function ermAdd() {
					layer.open({
						type: 1,
						title: '增加提醒',
						content: $('#ermAddRemind'),
						area: ["600px", "370px"]
					})
				};
				
				/*修改提醒*/
				$('.ermAmend').click(function(){
					ermAmend();
				});
				function ermAmend() {
					layer.open({
						type: 1,
						title: '修改提醒',
						content: $('#ermAddRemind'),
						area: ["600px", "370px"]
					})
				};

				/*判断库存下限的范围*/
                $('#proStockLower').bind('input',function () {
                    var proStockLower = $('#proStockLower').val();
                   	if(proStockLower < 0){
                   	    window.alert("库存下限不能为负数!");
                        $('#proStockLower').val(0);
					}
                });
			});
		</script>
	</body>

</html>